package com.neusoft.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5EncryptionUtil {
	
	public static String encrypted(String str) {
		try {
			MessageDigest md = MessageDigest.getInstance("MD5");
			byte[] digest = md.digest(str.getBytes());
			StringBuffer s = new StringBuffer();
			for(byte b : digest) {
				String hex = Integer.toHexString(0xFF & b);
				if(hex.length() == 1) {
					s.append("0");
				}
				s.append(hex);
			}
			return s.toString();
			
		} catch (NoSuchAlgorithmException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}
	}

}
